<?
    include('../config.php');
    session_start();
    if(!isset($_SESSION['username'])){
        header('Location:login.php');
    }
?>
<!DOCTYPE HTML>
<head>
	<meta http-equiv="content-type" content="text/html;charset=utf-8;" />
	<meta name="author" content="Ta Van Chinh" />
   <link rel="Shortcut Icon" href="/theme/images/icon.ico" type="image/x-icon" />
	<title>Hệ thống quản lý website</title>
   <?=$js?>
   <?=$css?> 
</head>

<body>
    <div id="list_product">
        <form>
        <div class="table_pro">
        <table style="font-size: 14px;color: #1C3A70; border:1px solid #ccc">
        <tr>
            <th>STT</th>
            <th>Loại sản phẩm</th>
            <th>Thuộc loại</th>
            <th>Vị trí</th>
            <th>Sửa</th>
            <th>Xóa</th>
        </tr>
        <?
            $arr_cate = getCate();
            $count  = count($arr_cate);
            $i=0;
            foreach($arr_cate as $key=>$value){
                $i++;
                if($value['cat_parent_id'] > 0) 
                  $cat_parent = $arr_cate[$value['cat_parent_id']]['cat_name'];
                else
                  $cat_parent = 'Danh mục gốc';
         ?>
                <tr>
                    <td style="text-align: center;"><?=$i?></td>
                    <td><?=$value['cat_name']?></td>
                    <td><?=$cat_parent?></td>
                    <td><?=$value['cat_position']?></td>
                    <td><a href="edit.php?cat_id=<?=base64_encode($value['cat_id'])?>">Sửa</a></td>
                    <td><a href="delete.php?cat_id=<?=base64_encode($value['cat_id'])?>">Xóa</a></td>
                </tr>
            <?}
        ?>
        </form>
        </table>
        </div>
    </div>
</body>
<style>
    td,th{
        border: 1px solid #ccc;
    }
</style>

</html>